﻿// 1.1.7.11. Write a program to find a sequence of neighbour numbers in an array, which has a sum of certain number S.
// Example: {4, 3, 1, 4, 2, 5, 8}, S=11 -> {4, 2, 5}.

using System;

class SumOfNeighbourNumbers
{
    static void Main()
    {
        int[] arr = { 4, 3, 1, 4, 2, 5, 8 };
        int userInput = int.Parse(Console.ReadLine());
        int beginSequence = 0;
        int endSequence = 0;
        for (int i = 0; i < arr.Length - 1; i++)
        {
            int currentSum = arr[i];
            for (int j = i + 1; j < arr.Length; j++)
            {
                currentSum += arr[j];
                if (currentSum == userInput)
                {
                    beginSequence = i;
                    endSequence = j;
                    break;
                }
            }
        }
        for (int i = beginSequence; i <= endSequence; i++)
        {
            if (i != endSequence)
            {
                Console.Write(arr[i] + " ");
            }
            else
            {
                Console.WriteLine(arr[i]);
            }
        }
    }
}